package com.bingbing.back.controller;

import com.bingbing.back.dto.AdminInfoDto;
import com.bingbing.back.po.AdminInfo;
import com.bingbing.back.service.AdminInfoService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@CrossOrigin
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Resource
    private AdminInfoService adminService;

    //根据输入条件搜索管理员
    @RequestMapping("/findByParam")
    public PageInfo<AdminInfo> findByParam(int pageNum, int pageSize, AdminInfoDto dto){
        PageInfo<AdminInfo> page=null;
        page=adminService.findByParam(pageNum,pageSize,dto);
        return page;
    }
    //根据管理员账号更新管理员信息，但账号不可更改
    @RequestMapping("/update")
    public int update(AdminInfoDto dto){
        int row=0;
        row=adminService.doUpdate(dto);
        return row;
    }
    /**
     * 根据管理员账号删除信息
     * @param adminId
     * @return
     */
    @RequestMapping("/delete")
    public int delete(int adminId){
        int row=0;
        row=adminService.doDelete(adminId);
        return row;
    }
    //批量删除操作
    @RequestMapping("/deleteMul")
    public int deleteMul(int[] adminIds){
        int row=0;
        row=adminService.doDeleteMul(adminIds);
        return row;
    }

}
